﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;


class MaxSum
{
    static int FindMaxSum(int[,] matrix)
    {
        int bestSum = int.MinValue;
        int sum = 0;
        for (int i = 0; i < matrix.GetLength(0)-1; i++)
        {
            for (int j = 0; j < matrix.GetLength(1)-1; j++)
            {
                sum = matrix[i, j] + matrix[i, j + 1] + matrix[i + 1, j] + matrix[i + 1, j + 1];
                if (sum > bestSum)
                {
                    bestSum = sum;
                }
                sum = 0;
            }
        }
        return bestSum;
    }
    static void Main(string[] args)
    {
        StreamReader input = new StreamReader("matrix.txt");
        StreamWriter output = new StreamWriter("ootput.txt");
        string line = "";
        string number = "";
        int sizeOfMatrix;
        int row = 0;
        int col = 0;
        using (input)
        {
            line = input.ReadLine();
            sizeOfMatrix = int.Parse(line);
            int[,] matrix = new int[sizeOfMatrix, sizeOfMatrix];
            while ((line = input.ReadLine()) != null)
            {
                foreach (var symbol in line)
                {
                    if (symbol != ' ')
                    {
                        number = number + symbol;
                    }
                    else
                    {
                        matrix[row, col] = int.Parse(number);
                        number = "";
                        col++;
                    }
                }
                matrix[row, col] = int.Parse(number);
                col = 0;
                row++;
                number = "";
            }
            using (output)
            {
                output.WriteLine(FindMaxSum(matrix));
            }

        }
    }
}

